package com.im.chat.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author chenmin
 * @since 2023-05-24
 * 聊天的命令枚举
 **/
@Getter
@AllArgsConstructor
public enum CommandType {
    CONNECTION(1001, "connect"),
    CHAT(1002, "chat"),
    JOIN_GROUP(1003, "group"),
    ERROR(-1, "error");

    private final Integer code;
    private final String type;

    public static CommandType match(Integer code) {
        for (CommandType value : CommandType.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return ERROR;
    }
}
